#include<bits/stdc++.h>
using namespace std;
const int N = 100000;
int main(void)
{

	int n, m, start, end;
	cin >> n >> m >> start >> end;
	vector<int>dist(n, N);
	dist[start] = 0;
	vector<int>cost(n, 0);
	vector<int>path(n, -1);
	vector<bool>visit(n, false);
	vector<vector<pair<int, int>>>board(n, vector<pair<int, int>>(n, make_pair(N, 0)));
	while (m--)
	{
		int a, b, s, money;
		cin >> a >> b >> s >> money;
		board[a][b].first = s;
		board[a][b].second = money;
		board[b][a].first = s;
		board[b][a].second = money;
	}
	int current = start;
	for (int i = 0; i < n; i++)
	{
		if (current == end)
			break;
		visit[current] = true;
		for (int j = 0; j < n; j++)
		{
			int newdist = dist[current] + board[current][j].first;
			int newcost = cost[current] + board[current][j].second;
			if (newdist < dist[j] || (newdist == dist[j] && newcost < cost[j]))
			{
				dist[j] = newdist;
				cost[j] = newcost;
			}
		}
		int Min = N, index;
		for (int j = 0; j < n; j++)
		{
			if (visit[j] == false && dist[j] < Min)
			{
				Min = dist[j];
				index = j;
			}
		}
		current = index;
	}
	cout << dist[end] << " " << cost[end];

	return 0;
}